package thread;

public class ThreadDemo7 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        // 还没由执行 start()，为 false
        System.out.println(t.isAlive());
        // 执行了 start() 为 true
        t.start();
        System.out.println(t.isAlive());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        // 执行完 run() 方法了，为 false
        System.out.println(t.isAlive());
    }
}
